#include <stdio.h>
#include <stdlib.h>
struct pos_t
{
    int x;
    int y;
};

int n;
int direction;
struct pos_t nextpoint;
struct pos_t pos;

enum
{
    SOUTH,
    WEST,
    NORTH,
    EAST
};

void nextpoint_update(int direction, int cyclecount);
void output(int *base);

int main(int argc, char *argv[])
{
    int *base = NULL;
    int cyclecount = 0;

    scanf("%d", &n);
    if(n<=0){
        printf("empty\n");
        return 0;
    }

    base = (int *)malloc(sizeof(int) * n * n);
    direction = SOUTH;
    pos.x = n - 1;
    pos.y = 0;
    nextpoint.x = n - 1;
    nextpoint.y = n - 1;

    *(base + pos.x + n * pos.y) = 1;
    for (int i = 2; i <= n * n; i++)
    {
        if (pos.x == nextpoint.x && pos.y == nextpoint.y)
        {
            direction++;
            if (direction > EAST)
                direction = SOUTH;
            if (pos.x == cyclecount && pos.y == cyclecount)
                cyclecount++;
            nextpoint_update(direction, cyclecount);
        }
        switch (direction)
        {
        case SOUTH:
            pos.y++;
            break;
        case WEST:
            pos.x--;
            break;
        case NORTH:
            pos.y--;
            break;
        case EAST:
            pos.x++;
            break;
        }
        *(base + pos.x + n * pos.y) = i;
    }

    output(base);
    free(base);

    return 0;
}

void nextpoint_update(int direction, int cyclecount)
{
    switch (direction)
    {
    case SOUTH:
        nextpoint.x = pos.x;
        nextpoint.y = n - 1 - cyclecount;
        break;
    case WEST:
        nextpoint.y = pos.y;
        nextpoint.x = cyclecount;
        break;
    case NORTH:
        nextpoint.x = pos.x;
        nextpoint.y = cyclecount;
        break;
    case EAST:
        nextpoint.y = pos.y;
        nextpoint.x = n - 1 - cyclecount;
        break;
    }
}
void output(int *base)
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n - 1; j++)
        {
            printf("%d ", *(base + j + n * i));
        }
        printf("%d\n", *(base + n - 1 + n * i));
    }
}
